<template>
	<view>
		<view class="container">
			<view class="time">
				<text>{{date}}</text>
			</view>
			<view class="msg">
				<view class="unRead">
					<view class="unReadTitle">
						<text>未读消息</text>
					</view>
					<view :class="[index%2==0?'massageRight':'massageLeft']" v-for="(items,index) in massageUnRead" :key="index"
					 :style="{backgroundColor:selectBg(items.text)}" @click="readMsg(items)">
						<text>{{items.time}} </text><text>{{items.text}}</text>
					</view>
				</view>
				<view class="read">
					<view class="readTitle">
						<text>已读消息</text>
					</view>
					<view :class="[index%2==0?'massageRight':'massageLeft']" v-for="(items,index) in massageUnRead" :key="index"
					 :style="{backgroundColor:'#DFDFDF'}">
						<text>{{items.time}} </text><text>{{items.text}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import vm from '../../utils/events.js'
	export default {
		data() {
			return {
				date: this.$p.getNowTimeDate(),
				massageUnRead: [{
					time: '08:35:15',
					text: '系统消息'
				}, {
					time: '08:35:15',
					text: '家庭号消息'
				}, {
					time: '08:35:15',
					text: '社区消息'
				}],
				massageRead: [{
					time: '08:35:15',
					text: '家庭号消息'
				}]


			};
		},
		methods: {
			selectBg(text) {
				if (text == '系统消息') {
					return '#FFB546';
				} else if (text == '家庭号消息') {
					return '#FF9A9A';
				} else if (text == '社区消息') {
					return '#4EB8F6';
				}
			},
			readMsg(items) {
				let data = {
					massage:false,
					massageRead:true
				}
				this.$emit('fmassage', data);
				vm.$emit('readMsg', items);

			}

		}
	}
</script>

<style>
	.container {
		width: 90%;
		height: 70vh;
		position: relative;
		top: -8vh;
		margin: 0 auto;
		background-color: #ffffff;
		/* border: 1rpx solid #000000; */
		border: 1px solid #bfbfbf;
		box-shadow: 0 0 10px 2px #bdcee0;
		border-radius: 3vw;
	}

	.time {
		width: 40vw;
		height: 5vh;
		display: block;
		justify-content: left;
		margin: 2vh 0 0 5vw;
		color: #BF4E12;
	}

	.msg {
		width: 100%;
		height: 60vh;
		overflow-y: scroll;
	}

	.unReadTitle {
		width: 40vw;
		height: 5vh;
		display: block;
		justify-content: left;
		margin: 2vh 0 0 5vw;
		font-size: 48rpx;
		font-weight: bold;
	}

	.massageRight {
		width: 70%;
		height: 8vh;
		background-color: #007AFF;
		text-align: center;
		line-height: 100rpx;
		font-size: 42rpx;
		float: right;
		margin-right: 10vw;
		margin-top: 2vh;
		border-radius: 4vh 4vh 0 4vh;
	}

	.massageLeft {
		width: 70%;
		height: 8vh;
		background-color: #007AFF;
		text-align: center;
		line-height: 100rpx;
		font-size: 42rpx;
		float: left;
		margin-left: 10vw;
		margin-top: 2vh;
		border-radius: 4vh 4vh 4vh 0vh;
	}

	.readTitle {
		float: left;
		margin: 2vh 0 0 5vw;
		width: 40vw;
		height: 5vh;
		font-size: 48rpx;
		font-weight: bold;

	}
</style>
